# == Schema Information
#
# Table name: reserves
#
#  id            :integer          not null, primary key
#  user_id       :integer
#  survey_fee_id :integer
#  desc          :text
#  created_at    :datetime         not null
#  updated_at    :datetime         not null
#  address_id    :integer
#  franchiser_id :integer
#  cellphone     :string
#  contact_name  :string
#

class Reserve < ApplicationRecord

  validates :address_id, presence: { message: "地址不能为空" }
  validates :user_id, presence: { message: "手机号不能为空" }
  validates :survey_fee_id, presence: { message: "测量费用不能为空" }
  #validates :franchiser_id, presence: { message: "供应商不能为空" }
  #validates :desc, presence: { message: "测量详情不能为空" }
  validates :contact_name, presence: { message: "联系人姓名不能为空" }
  #validates :address_desc, presence: { message: "详细地址不能为空" }

  has_one :order
  belongs_to :survey_fee
  belongs_to :address

  delegate :amount, to: :survey_fee, prefix: :survey_fee
  delegate :name, to: :survey_fee, prefix: :survey_fee

  attr_accessor :address_desc
end
